package com.atao.example.stream01;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 阿涛
 * @date 2021-03-07
 */
public class Test {

    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("浮小麦");
        list.add("胡黄连");
        list.add("银柴胡");
        list.add("青蒿");
        for (String medecine : list) {
            if (medecine.startsWith("青") && medecine.length()==2)
                System.out.println("抓药：" + medecine);
        }
        //todo stream流式处理
        list.stream().filter(medicine->medicine.startsWith("青")).filter(medicine->medicine.length()==2)
                .forEach(medicine-> System.out.println("stream流抓药：" + medicine));
    }

}
